package d1_3element;

import java.net.InetAddress;
import java.net.UnknownHostException;

import static java.net.InetAddress.getLocalHost;

public class InetAddressTest {
    public static void main(String[] args) throws Exception {
        InetAddress ip1 = InetAddress.getLocalHost();
        System.out.println(ip1.getHostName());
        System.out.println(ip1.getHostAddress());

        InetAddress ip2 = InetAddress.getByName("www.bilibili.com");
        System.out.println(ip2.getHostName());
        System.out.println(ip2.getHostAddress());

        //ping www.bilibili.com
        boolean s = ip2.isReachable(1000);
        System.out.println(s);
    }
}
